#ifndef MICROHOST_H
#define MICROHOST_H

#include "free-cube/ahost.h"
#include "free-cube/ahosthandler.h"
#include "free-cube/amasterhandler.h"
#include "free-cube/buffer.h"
#include "free-cube/freecube.h"
#include <QSharedPointer>

class MainWindow;
class RefreshTimer;
class PluginRack;


namespace fc {
class AIRefresher;
class AISequencer;
class AIClock;
}

class MicroHost : public fc::AHost,
        public fc::AHostHandler,
        public fc::AMasterHandler
{
public:
    MicroHost();
    ~MicroHost();
    bool init();
    void shutdown();
    void load_plugin(fc::APlugin & plugin);
    void set_driver(QSharedPointer<fc::ADriver> driver);
    void show();
    void show_driver_panel();
    fc::HostHandler & handler();

// AHostHandler
    void process();
    void sample_rate_changed();
    void buffer_size_changed();
    void connection_changed();

// AMasterHandler
    void connect_plugins_data(int out, int in);

private:

    static fc::Buffer buffer_;    
    QSharedPointer<fc::AISequencer> sequencer_;
    QSharedPointer<fc::AIRefresher> timer_;
    QSharedPointer<fc::ADriver> driver_;
    QSharedPointer<MainWindow> main_window_;
    QSharedPointer<fc::AIClock> clock_;
    QSharedPointer<PluginRack> rack_;
    bool is_stopped_;

};

#endif // MICROHOST_H
